package rmhc.server
{
	import flash.utils.ByteArray;
	
	public class FileEntry extends MultipartEntry
	{
		public var filename:String;
		public var data:ByteArray;
		
		protected var type:String;
		
		public function FileEntry( name:String , filename:String , data:ByteArray , type:String = "application/octet-stream" )
		{
			super( name , null );
			
			this.filename = filename;
			this.data = data;
			this.type = type;
		}
		
		public override function appendTo( ba:ByteArray , boundary:String ):void
		{
			ba.writeUTFBytes( "--" + boundary + rn );
			//ba.writeUTFBytes( 'Content-Disposition: form-data; name="' + name + '[]"; filename="' + filename + '"' + rn );
			ba.writeUTFBytes( 'Content-Disposition: form-data; name="' + name + '"; filename="' + filename + '"' + rn );
			ba.writeUTFBytes( "Content-Type: " + type + rn );
			ba.writeUTFBytes( "Content-Transfer-Encoding: binary" + rn + rn );
			ba.writeBytes( data );
			ba.writeShort( 0x0d0a );
		}
	}	
}